package com.csr.csrcheck.controller;

import com.csr.csrcheck.controller.ex.ProductException;
import com.csr.csrcheck.pojo.Product;
import com.csr.csrcheck.service.Product_apparatusService;
import com.csr.csrcheck.util.JsonResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping({"product"})
public class Product_apparatusController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(com.csr.csrcheck.controller.Product_apparatusController.class);

    @Resource
    private Product_apparatusService product_apparatusService;

    @GetMapping({"produc_apparatustlist"})
    public JsonResult<List<Product>> Productlistbyname(@RequestParam("name") String name) {
        List<Product> list = this.product_apparatusService.getProductlistbyname(name);
        if (list == null)
            throw new ProductException("");
        return new JsonResult(Integer.valueOf(0), "json", list);
    }
}
